//
//  FindModel.m
//  FD
//
//  Created by Yasin on 2018/10/19.
//  Copyright © 2018年 ZhiYuan Network. All rights reserved.
//

#import "FindModel.h"

@implementation FindModel

+ (NSDictionary *)mj_replacedKeyFromPropertyName {
    return @{@"couponId":@"id"};
}

- (NSString *)description {
    NSArray *ptyArr = [FindModel rb_objPropeties];
    return [[self dictionaryWithValuesForKeys:ptyArr] description];
}

- (NSString *)thumbnail {
    return [NSString stringWithFormat:@"%@%@",kPicDomain,_thumbnail];
}

- (void)setUser:(NSDictionary *)user {
    _user = user;
    
    if (user == nil) return;
    
    NSNumber *receive = user[@"receive"];
    if ([receive isEqualToNumber:@0]) { //0否  1是
        _isReceive = NO;
    }else {
        _isReceive = YES;
    }
}


//内部处理
- (void)setActiveDate:(NSNumber *)activeDate {
    _activeDate = activeDate;
    
    NSString *timeStamp = [NSString stringWithFormat:@"%@",activeDate];

    //赋值
     _beginTimeStr = [self stringFromTimeStamp:timeStamp];
}

- (void)setQuietDate:(NSNumber *)quietDate {
    _quietDate = quietDate;
    
    NSString *timeStamp = [NSString stringWithFormat:@"%@",quietDate];
    
    _endTimeStr = [self stringFromTimeStamp:timeStamp];

}


//时间戳转时间
- (NSString *)stringFromTimeStamp:(NSString *)timeStamp {
    // timeStampString 是服务器返回的13位时间戳
    
    // iOS 生成的时间戳是10位
    NSTimeInterval interval    =[timeStamp doubleValue] / 1000.0;
    NSDate *date               = [NSDate dateWithTimeIntervalSince1970:interval];
    
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateFormat:@"yyyy-MM-dd"];
    NSString *dateString       = [formatter stringFromDate: date];
    
    return dateString;
}



@end
